
package com.ukao.pad.presenter;

import android.content.Context;

import com.ukao.pad.base.BasePresenter;
import com.ukao.pad.bean.AddClothingItem;
import com.ukao.pad.bean.RecheckBean;
import com.ukao.pad.bean.StringBean;
import com.ukao.pad.consts.Constant;
import com.ukao.pad.consts.SaveParamets;
import com.ukao.pad.retrofit.ApiCallback;
import com.ukao.pad.utils.Utils;
import com.ukao.pad.view.RecheckView;

import java.util.HashMap;

/**
 * Created by ukaodev on 2017/6/28.
 */

public class RecheckPesenter extends BasePresenter<RecheckView> {


    public RecheckPesenter(RecheckView view) {
        attachView(view);
    }



    /*修改提交*/
    public void orderProductUpdate(HashMap mHashMap,final   int  pos) {
        mvpView.showLoading();
        addSubscription(apiStores.orderProductUpdate(Constant.createParameter(mHashMap)),
                new ApiCallback<StringBean>() {
                    @Override
                    public void onSuccess(StringBean model) {

                        if (model.getHttpCode() == 200) {
                            mvpView.loadUpdataSucceed(pos);

                        }else{
                            mvpView.loadUpdataFail(model.getMsg(),pos);

                        }
                    }

                    @Override
                    public void onNoNewWork() {

                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }
                });
    }


    /*搜索条码*/
    public void stationScanCode(Context context, String  batchCode  ) {
        mvpView.showLoading();
        HashMap mHashMap=new HashMap<String,String>();
        mHashMap.put("scanCode",batchCode);/*衣物条码*/
        mHashMap.put("accessToken", SaveParamets.getToken(context));
        addSubscription(apiStores.stationScanCode(Constant.createParameter(mHashMap)),
                new ApiCallback<RecheckBean>() {
                    @Override
                    public void onSuccess(RecheckBean model) {

                        if (model.getHttpCode() == 200) {
                            mvpView.loadStockReworkSucceed(model.getData());

                        }else{
                            mvpView.loadStockReworkFail(model.getMsg());

                        }
                    }

                    @Override
                    public void onNoNewWork() {

                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }
                });
    }


    /*附件*/
    public void annexDescRequest(String productId ) {
        HashMap mHashMap = new HashMap<String, String>();
        mHashMap.put("businessId", productId);
        mHashMap.put("accessToken", SaveParamets.getToken(Utils.getContext()));
        addSubscription(apiStores.productAnnex(Constant.createParameter(mHashMap)),
                new ApiCallback<AddClothingItem>() {
                    @Override
                    public void onSuccess(AddClothingItem model) {
                        if (model.getHttpCode()==200){
                            mvpView.annexDescSucceed(model.getData());
                        }else{
                            mvpView.loadFail(model.getMsg());
                        }


                    }

                    @Override
                    public void onNoNewWork() {

                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }

                });
    }


    /**
     *项目       productId
     */
    public void projectData(    int pos) {

        mvpView.showLoading();
        switch (pos){
            case  2: /*品牌*/
                productBrand();
                break;
            case  3: /*颜色*/
                productColor();

                break;
            case  4: /*瑕疵*/
                productFlaw();
                break;
            case  5: /*洗后效果*/
                productEffect();
                break;


        }





}

    /*品牌*/
    public void productBrand(   ) {
        HashMap mHashMap=new HashMap<String,String>();
        mHashMap.put("accessToken", SaveParamets.getToken(Utils.getContext()));
        addSubscription(apiStores.productBrand(Constant.createParameter(mHashMap)),
                new ApiCallback<AddClothingItem>() {
                    @Override
                    public void onSuccess(AddClothingItem model) {
                        if (model.getHttpCode()==200){
                            mvpView.loadBrandData(model.getData());
                        }else{
                            mvpView.loadFail(model.getMsg());
                        }


                    }

                    @Override
                    public void onNoNewWork() {

                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }

                });
    }
    /*颜色*/
    public void productColor(   ) {
        HashMap mHashMap=new HashMap<String,String>();
        mHashMap.put("accessToken", SaveParamets.getToken(Utils.getContext()));
        addSubscription(apiStores.productColor(Constant.createParameter(mHashMap)),
                new ApiCallback<AddClothingItem>() {
                    @Override
                    public void onSuccess(AddClothingItem model) {
                        if (model.getHttpCode()==200){
                            mvpView.loadColorData(model.getData());
                        }else{
                            mvpView.loadFail(model.getMsg());
                        }


                    }

                    @Override
                    public void onNoNewWork() {

                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }

                });
    }
    /*瑕疵*/
    public void productFlaw(   ) {
        HashMap mHashMap=new HashMap<String,String>();
        mHashMap.put("accessToken", SaveParamets.getToken(Utils.getContext()));
        addSubscription(apiStores.productFlaw(Constant.createParameter(mHashMap)),
                new ApiCallback<AddClothingItem>() {
                    @Override
                    public void onSuccess(AddClothingItem model) {
                        if (model.getHttpCode()==200){
                            mvpView.loadFlawData(model.getData());
                        }else{
                            mvpView.loadFail(model.getMsg());
                        }


                    }

                    @Override
                    public void onNoNewWork() {

                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }

                });
    }
    /*洗后效果*/
    public void productEffect(   ) {
        HashMap mHashMap=new HashMap<String,String>();
        mHashMap.put("accessToken", SaveParamets.getToken(Utils.getContext()));
        addSubscription(apiStores.productEffect(Constant.createParameter(mHashMap)),
                new ApiCallback<AddClothingItem>() {
                    @Override
                    public void onSuccess(AddClothingItem model) {
                        if (model.getHttpCode()==200){
                            mvpView.loadEffectData(model.getData());
                        }else{
                            mvpView.loadFail(model.getMsg());
                        }


                    }

                    @Override
                    public void onNoNewWork() {

                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }

                });
    }
}
